import pygetwindow as gw
from PIL import ImageGrab, Image
 
# 截取屏幕区域作为图片
screenshot = ImageGrab.grab()
 
# 要查找的图片路径
search_image_path = 'path_to_your_search_image.png'
 
# 加载要查找的图片
search_image = Image.open(search_image_path)
 
# 在屏幕截图中查找图片
# 将返回一个窗口列表，这些窗口与搜索图像匹配
matches = gw.find_images(screenshot, search_image)
 
# 输出匹配的窗口
for match in matches:
    print(match)